import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int [] array = initArray();

        boolean flag = true;
        while (flag){
            System.out.println("哥哥你还要继续吗？（1继续，其他结束；结束输出小女孩猜的数）");
            int game = scanner.nextInt();
            if (game==1){
                int [] guessArray = guessNumber();
                judgeArray(array,guessArray);
            }else {
                System.out.println("游戏结束，我猜的数字是");
                for (int i = 0; i < 4; i++) {
                    System.out.print(array[i]+" ");
                }
                System.out.println("猜不到吧");
                break;
            }
        }

    }
    public static int [] guessNumber(){
        int [] guessArray = new int[4];
        for (int i = 0; i < 4; i++) {
            System.out.println("请输入第"+(i+1)+"个数：");
            Scanner scanner = new Scanner(System.in);
            int scannerNumber = scanner.nextInt();
            guessArray[i] = scannerNumber;
        }
        return guessArray;
    }



    public static int[] initArray(){
        int array[] = new int[4];
        /*
         * 创建随机数并写入数组
         * */
        Random random = new Random();
        for (int i = 0; i < 4; i++) {
            int randomNumber = random.nextInt(10);
            array[i] = randomNumber;
        }

        return array;
    }

    public static void judgeArray(int[] array ,int[] guessArray){
        boolean [] judgeArray = new boolean[4];
        for (int i = 0; i < 4; i++) {
//            System.out.println("随机生成的array==="+array[i]);
//            System.out.println("我猜测的数组guessArray"+guessArray[i]);
            if (array[i]==guessArray[i]){
                judgeArray[i] = true;
            }else {
                judgeArray[i] = false;
            }
        }
        System.out.println("开始说话了");
        countArray(judgeArray);
//        System.out.println(judgeArray);
//        for (int i = 0; i < 4; i++) {
//            System.out.println(judgeArray[i]);
//        }
    }
    public static void countArray(boolean [] judgeArray){
        int T = 0, F = 0;
        for (int i = 0; i < 4; i++) {
//            System.out.println(judgeArray[i]);
            if (judgeArray[i]==true){
                T+=1;
            }else {
                F+=1;
            }
        }
        if (T>0){
            if (T==4){
                System.out.println("4阳，全对了");
            }else {
                System.out.println(T+"阳，"+F+"阴");
            }
        }else {
            System.out.println("你没有猜对哦");
        }
    }
}
